package com.gitee.wsl.data.store.db

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update

@Dao
interface KVStoreDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(itemList: List<KVStore>): List<Long>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(item: KVStore): Long

    @Update
    suspend fun update(item: KVStore): Int

    @Delete
    suspend fun delete(item: KVStore):Unit

    @Delete
    suspend fun delete(itemList: List<KVStore>):Unit

    @Query("SELECT * FROM kv_store WHERE keyId IS :keyID")
    suspend fun loadKV(keyID: String): KVStore?

    @Query("DELETE FROM kv_store WHERE keyId IS :keyID")
    suspend fun delete(keyID: String):Unit

    @Query("UPDATE kv_store SET value=:valueStr WHERE keyId IS :keyID")
    suspend fun setValue(keyID: String,valueStr: String):Unit
}